package thread;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2023-11-27  17:06
 */
public class ThreadDemo16 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            int n = 50;
            for(int i = 0; i < n; i++) {
                System.out.println("线程运行第" + i + "次！");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        },"线程1");
        System.out.println(thread.getState());
        thread.start();
        System.out.println(thread.getState());
        thread.join();
        System.out.println(thread.getState());

    }
}
